/*
 * Copyright 2018 Google
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: firestore/local/maybe_document.proto

#include "firestore/local/maybe_document.pb.h"

#include <algorithm>

#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/port.h>
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/wire_format_lite_inl.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
// This is a temporary google only hack
#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
#include "third_party/protobuf/version.h"
#endif
// @@protoc_insertion_point(includes)
namespace firestore {
namespace client {
class NoDocumentDefaultTypeInternal {
 public:
  ::google::protobuf::internal::ExplicitlyConstructed<NoDocument>
      _instance;
} _NoDocument_default_instance_;
class UnknownDocumentDefaultTypeInternal {
 public:
  ::google::protobuf::internal::ExplicitlyConstructed<UnknownDocument>
      _instance;
} _UnknownDocument_default_instance_;
class MaybeDocumentDefaultTypeInternal {
 public:
  ::google::protobuf::internal::ExplicitlyConstructed<MaybeDocument>
      _instance;
  const ::firestore::client::NoDocument* no_document_;
  const ::google::firestore::v1beta1::Document* document_;
  const ::firestore::client::UnknownDocument* unknown_document_;
} _MaybeDocument_default_instance_;
}  // namespace client
}  // namespace firestore
namespace protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto {
void InitDefaultsNoDocumentImpl() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
  ::google::protobuf::internal::InitProtobufDefaultsForceUnique();
#else
  ::google::protobuf::internal::InitProtobufDefaults();
#endif  // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
  protobuf_google_2fprotobuf_2ftimestamp_2eproto::InitDefaultsTimestamp();
  {
    void* ptr = &::firestore::client::_NoDocument_default_instance_;
    new (ptr) ::firestore::client::NoDocument();
    ::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
  }
  ::firestore::client::NoDocument::InitAsDefaultInstance();
}

void InitDefaultsNoDocument() {
  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
  ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsNoDocumentImpl);
}

void InitDefaultsUnknownDocumentImpl() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
  ::google::protobuf::internal::InitProtobufDefaultsForceUnique();
#else
  ::google::protobuf::internal::InitProtobufDefaults();
#endif  // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
  protobuf_google_2fprotobuf_2ftimestamp_2eproto::InitDefaultsTimestamp();
  {
    void* ptr = &::firestore::client::_UnknownDocument_default_instance_;
    new (ptr) ::firestore::client::UnknownDocument();
    ::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
  }
  ::firestore::client::UnknownDocument::InitAsDefaultInstance();
}

void InitDefaultsUnknownDocument() {
  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
  ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsUnknownDocumentImpl);
}

void InitDefaultsMaybeDocumentImpl() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
  ::google::protobuf::internal::InitProtobufDefaultsForceUnique();
#else
  ::google::protobuf::internal::InitProtobufDefaults();
#endif  // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
  protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto::InitDefaultsNoDocument();
  protobuf_google_2ffirestore_2fv1beta1_2fdocument_2eproto::InitDefaultsDocument();
  protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto::InitDefaultsUnknownDocument();
  {
    void* ptr = &::firestore::client::_MaybeDocument_default_instance_;
    new (ptr) ::firestore::client::MaybeDocument();
    ::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
  }
  ::firestore::client::MaybeDocument::InitAsDefaultInstance();
}

void InitDefaultsMaybeDocument() {
  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
  ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsMaybeDocumentImpl);
}

::google::protobuf::Metadata file_level_metadata[3];

const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
  ~0u,  // no _has_bits_
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::NoDocument, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::NoDocument, name_),
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::NoDocument, read_time_),
  ~0u,  // no _has_bits_
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::UnknownDocument, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::UnknownDocument, name_),
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::UnknownDocument, version_),
  ~0u,  // no _has_bits_
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::MaybeDocument, _internal_metadata_),
  ~0u,  // no _extensions_
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::MaybeDocument, _oneof_case_[0]),
  ~0u,  // no _weak_field_map_
  offsetof(::firestore::client::MaybeDocumentDefaultTypeInternal, no_document_),
  offsetof(::firestore::client::MaybeDocumentDefaultTypeInternal, document_),
  offsetof(::firestore::client::MaybeDocumentDefaultTypeInternal, unknown_document_),
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::MaybeDocument, has_committed_mutations_),
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::MaybeDocument, document_type_),
};
static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
  { 0, -1, sizeof(::firestore::client::NoDocument)},
  { 7, -1, sizeof(::firestore::client::UnknownDocument)},
  { 14, -1, sizeof(::firestore::client::MaybeDocument)},
};

static ::google::protobuf::Message const * const file_default_instances[] = {
  reinterpret_cast<const ::google::protobuf::Message*>(&::firestore::client::_NoDocument_default_instance_),
  reinterpret_cast<const ::google::protobuf::Message*>(&::firestore::client::_UnknownDocument_default_instance_),
  reinterpret_cast<const ::google::protobuf::Message*>(&::firestore::client::_MaybeDocument_default_instance_),
};

void protobuf_AssignDescriptors() {
  AddDescriptors();
  ::google::protobuf::MessageFactory* factory = NULL;
  AssignDescriptors(
      "firestore/local/maybe_document.proto", schemas, file_default_instances, TableStruct::offsets, factory,
      file_level_metadata, NULL, NULL);
}

void protobuf_AssignDescriptorsOnce() {
  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
  ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
}

void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD;
void protobuf_RegisterTypes(const ::std::string&) {
  protobuf_AssignDescriptorsOnce();
  ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 3);
}

void AddDescriptorsImpl() {
  InitDefaults();
  static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
      "\n$firestore/local/maybe_document.proto\022\020"
      "firestore.client\032\'google/firestore/v1bet"
      "a1/document.proto\032\037google/protobuf/times"
      "tamp.proto\"I\n\nNoDocument\022\014\n\004name\030\001 \001(\t\022-"
      "\n\tread_time\030\002 \001(\0132\032.google.protobuf.Time"
      "stamp\"L\n\017UnknownDocument\022\014\n\004name\030\001 \001(\t\022+"
      "\n\007version\030\002 \001(\0132\032.google.protobuf.Timest"
      "amp\"\355\001\n\rMaybeDocument\0223\n\013no_document\030\001 \001"
      "(\0132\034.firestore.client.NoDocumentH\000\0226\n\010do"
      "cument\030\002 \001(\0132\".google.firestore.v1beta1."
      "DocumentH\000\022=\n\020unknown_document\030\003 \001(\0132!.f"
      "irestore.client.UnknownDocumentH\000\022\037\n\027has"
      "_committed_mutations\030\004 \001(\010B\017\n\rdocument_t"
      "ypeB/\n#com.google.firebase.firestore.pro"
      "toP\001\242\002\005FSTPBb\006proto3"
  };
  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
      descriptor, 580);
  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
    "firestore/local/maybe_document.proto", &protobuf_RegisterTypes);
  ::protobuf_google_2ffirestore_2fv1beta1_2fdocument_2eproto::AddDescriptors();
  ::protobuf_google_2fprotobuf_2ftimestamp_2eproto::AddDescriptors();
}

void AddDescriptors() {
  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
  ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
}
// Force AddDescriptors() to be called at dynamic initialization time.
struct StaticDescriptorInitializer {
  StaticDescriptorInitializer() {
    AddDescriptors();
  }
} static_descriptor_initializer;
}  // namespace protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto
namespace firestore {
namespace client {

// ===================================================================

void NoDocument::InitAsDefaultInstance() {
  ::firestore::client::_NoDocument_default_instance_._instance.get_mutable()->read_time_ = const_cast< ::google::protobuf::Timestamp*>(
      ::google::protobuf::Timestamp::internal_default_instance());
}
void NoDocument::clear_read_time() {
  if (GetArenaNoVirtual() == NULL && read_time_ != NULL) {
    delete read_time_;
  }
  read_time_ = NULL;
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int NoDocument::kNameFieldNumber;
const int NoDocument::kReadTimeFieldNumber;
#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900

NoDocument::NoDocument()
  : ::google::protobuf::Message(), _internal_metadata_(NULL) {
  if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
    ::protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto::InitDefaultsNoDocument();
  }
  SharedCtor();
  // @@protoc_insertion_point(constructor:firestore.client.NoDocument)
}
NoDocument::NoDocument(const NoDocument& from)
  : ::google::protobuf::Message(),
      _internal_metadata_(NULL),
      _cached_size_(0) {
  _internal_metadata_.MergeFrom(from._internal_metadata_);
  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  if (from.name().size() > 0) {
    name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
  }
  if (from.has_read_time()) {
    read_time_ = new ::google::protobuf::Timestamp(*from.read_time_);
  } else {
    read_time_ = NULL;
  }
  // @@protoc_insertion_point(copy_constructor:firestore.client.NoDocument)
}

void NoDocument::SharedCtor() {
  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  read_time_ = NULL;
  _cached_size_ = 0;
}

NoDocument::~NoDocument() {
  // @@protoc_insertion_point(destructor:firestore.client.NoDocument)
  SharedDtor();
}

void NoDocument::SharedDtor() {
  name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  if (this != internal_default_instance()) delete read_time_;
}

void NoDocument::SetCachedSize(int size) const {
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* NoDocument::descriptor() {
  ::protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto::protobuf_AssignDescriptorsOnce();
  return ::protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}

const NoDocument& NoDocument::default_instance() {
  ::protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto::InitDefaultsNoDocument();
  return *internal_default_instance();
}

NoDocument* NoDocument::New(::google::protobuf::Arena* arena) const {
  NoDocument* n = new NoDocument;
  if (arena != NULL) {
    arena->Own(n);
  }
  return n;
}

void NoDocument::Clear() {
// @@protoc_insertion_point(message_clear_start:firestore.client.NoDocument)
  ::google::protobuf::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  if (GetArenaNoVirtual() == NULL && read_time_ != NULL) {
    delete read_time_;
  }
  read_time_ = NULL;
  _internal_metadata_.Clear();
}

bool NoDocument::MergePartialFromCodedStream(
    ::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
  ::google::protobuf::uint32 tag;
  // @@protoc_insertion_point(parse_start:firestore.client.NoDocument)
  for (;;) {
    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
    tag = p.first;
    if (!p.second) goto handle_unusual;
    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
      // string name = 1;
      case 1: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) {
          DO_(::google::protobuf::internal::WireFormatLite::ReadString(
                input, this->mutable_name()));
          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
            this->name().data(), static_cast<int>(this->name().length()),
            ::google::protobuf::internal::WireFormatLite::PARSE,
            "firestore.client.NoDocument.name"));
        } else {
          goto handle_unusual;
        }
        break;
      }

      // .google.protobuf.Timestamp read_time = 2;
      case 2: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) {
          DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
               input, mutable_read_time()));
        } else {
          goto handle_unusual;
        }
        break;
      }

      default: {
      handle_unusual:
        if (tag == 0) {
          goto success;
        }
        DO_(::google::protobuf::internal::WireFormat::SkipField(
              input, tag, _internal_metadata_.mutable_unknown_fields()));
        break;
      }
    }
  }
success:
  // @@protoc_insertion_point(parse_success:firestore.client.NoDocument)
  return true;
failure:
  // @@protoc_insertion_point(parse_failure:firestore.client.NoDocument)
  return false;
#undef DO_
}

void NoDocument::SerializeWithCachedSizes(
    ::google::protobuf::io::CodedOutputStream* output) const {
  // @@protoc_insertion_point(serialize_start:firestore.client.NoDocument)
  ::google::protobuf::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // string name = 1;
  if (this->name().size() > 0) {
    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
      this->name().data(), static_cast<int>(this->name().length()),
      ::google::protobuf::internal::WireFormatLite::SERIALIZE,
      "firestore.client.NoDocument.name");
    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
      1, this->name(), output);
  }

  // .google.protobuf.Timestamp read_time = 2;
  if (this->has_read_time()) {
    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
      2, *this->read_time_, output);
  }

  if ((_internal_metadata_.have_unknown_fields() &&  ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
        (::google::protobuf::internal::GetProto3PreserveUnknownsDefault()   ? _internal_metadata_.unknown_fields()   : _internal_metadata_.default_instance()), output);
  }
  // @@protoc_insertion_point(serialize_end:firestore.client.NoDocument)
}

::google::protobuf::uint8* NoDocument::InternalSerializeWithCachedSizesToArray(
    bool deterministic, ::google::protobuf::uint8* target) const {
  (void)deterministic; // Unused
  // @@protoc_insertion_point(serialize_to_array_start:firestore.client.NoDocument)
  ::google::protobuf::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // string name = 1;
  if (this->name().size() > 0) {
    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
      this->name().data(), static_cast<int>(this->name().length()),
      ::google::protobuf::internal::WireFormatLite::SERIALIZE,
      "firestore.client.NoDocument.name");
    target =
      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
        1, this->name(), target);
  }

  // .google.protobuf.Timestamp read_time = 2;
  if (this->has_read_time()) {
    target = ::google::protobuf::internal::WireFormatLite::
      InternalWriteMessageToArray(
        2, *this->read_time_, deterministic, target);
  }

  if ((_internal_metadata_.have_unknown_fields() &&  ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
        (::google::protobuf::internal::GetProto3PreserveUnknownsDefault()   ? _internal_metadata_.unknown_fields()   : _internal_metadata_.default_instance()), target);
  }
  // @@protoc_insertion_point(serialize_to_array_end:firestore.client.NoDocument)
  return target;
}

size_t NoDocument::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:firestore.client.NoDocument)
  size_t total_size = 0;

  if ((_internal_metadata_.have_unknown_fields() &&  ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
    total_size +=
      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
        (::google::protobuf::internal::GetProto3PreserveUnknownsDefault()   ? _internal_metadata_.unknown_fields()   : _internal_metadata_.default_instance()));
  }
  // string name = 1;
  if (this->name().size() > 0) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::StringSize(
        this->name());
  }

  // .google.protobuf.Timestamp read_time = 2;
  if (this->has_read_time()) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::MessageSize(
        *this->read_time_);
  }

  int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = cached_size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
  return total_size;
}

void NoDocument::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:firestore.client.NoDocument)
  GOOGLE_DCHECK_NE(&from, this);
  const NoDocument* source =
      ::google::protobuf::internal::DynamicCastToGenerated<const NoDocument>(
          &from);
  if (source == NULL) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:firestore.client.NoDocument)
    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:firestore.client.NoDocument)
    MergeFrom(*source);
  }
}

void NoDocument::MergeFrom(const NoDocument& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:firestore.client.NoDocument)
  GOOGLE_DCHECK_NE(&from, this);
  _internal_metadata_.MergeFrom(from._internal_metadata_);
  ::google::protobuf::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  if (from.name().size() > 0) {

    name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
  }
  if (from.has_read_time()) {
    mutable_read_time()->::google::protobuf::Timestamp::MergeFrom(from.read_time());
  }
}

void NoDocument::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:firestore.client.NoDocument)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void NoDocument::CopyFrom(const NoDocument& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:firestore.client.NoDocument)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool NoDocument::IsInitialized() const {
  return true;
}

void NoDocument::Swap(NoDocument* other) {
  if (other == this) return;
  InternalSwap(other);
}
void NoDocument::InternalSwap(NoDocument* other) {
  using std::swap;
  name_.Swap(&other->name_);
  swap(read_time_, other->read_time_);
  _internal_metadata_.Swap(&other->_internal_metadata_);
  swap(_cached_size_, other->_cached_size_);
}

::google::protobuf::Metadata NoDocument::GetMetadata() const {
  protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto::protobuf_AssignDescriptorsOnce();
  return ::protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto::file_level_metadata[kIndexInFileMessages];
}


// ===================================================================

void UnknownDocument::InitAsDefaultInstance() {
  ::firestore::client::_UnknownDocument_default_instance_._instance.get_mutable()->version_ = const_cast< ::google::protobuf::Timestamp*>(
      ::google::protobuf::Timestamp::internal_default_instance());
}
void UnknownDocument::clear_version() {
  if (GetArenaNoVirtual() == NULL && version_ != NULL) {
    delete version_;
  }
  version_ = NULL;
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int UnknownDocument::kNameFieldNumber;
const int UnknownDocument::kVersionFieldNumber;
#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900

UnknownDocument::UnknownDocument()
  : ::google::protobuf::Message(), _internal_metadata_(NULL) {
  if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
    ::protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto::InitDefaultsUnknownDocument();
  }
  SharedCtor();
  // @@protoc_insertion_point(constructor:firestore.client.UnknownDocument)
}
UnknownDocument::UnknownDocument(const UnknownDocument& from)
  : ::google::protobuf::Message(),
      _internal_metadata_(NULL),
      _cached_size_(0) {
  _internal_metadata_.MergeFrom(from._internal_metadata_);
  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  if (from.name().size() > 0) {
    name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
  }
  if (from.has_version()) {
    version_ = new ::google::protobuf::Timestamp(*from.version_);
  } else {
    version_ = NULL;
  }
  // @@protoc_insertion_point(copy_constructor:firestore.client.UnknownDocument)
}

void UnknownDocument::SharedCtor() {
  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  version_ = NULL;
  _cached_size_ = 0;
}

UnknownDocument::~UnknownDocument() {
  // @@protoc_insertion_point(destructor:firestore.client.UnknownDocument)
  SharedDtor();
}

void UnknownDocument::SharedDtor() {
  name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  if (this != internal_default_instance()) delete version_;
}

void UnknownDocument::SetCachedSize(int size) const {
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* UnknownDocument::descriptor() {
  ::protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto::protobuf_AssignDescriptorsOnce();
  return ::protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}

const UnknownDocument& UnknownDocument::default_instance() {
  ::protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto::InitDefaultsUnknownDocument();
  return *internal_default_instance();
}

UnknownDocument* UnknownDocument::New(::google::protobuf::Arena* arena) const {
  UnknownDocument* n = new UnknownDocument;
  if (arena != NULL) {
    arena->Own(n);
  }
  return n;
}

void UnknownDocument::Clear() {
// @@protoc_insertion_point(message_clear_start:firestore.client.UnknownDocument)
  ::google::protobuf::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  if (GetArenaNoVirtual() == NULL && version_ != NULL) {
    delete version_;
  }
  version_ = NULL;
  _internal_metadata_.Clear();
}

bool UnknownDocument::MergePartialFromCodedStream(
    ::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
  ::google::protobuf::uint32 tag;
  // @@protoc_insertion_point(parse_start:firestore.client.UnknownDocument)
  for (;;) {
    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
    tag = p.first;
    if (!p.second) goto handle_unusual;
    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
      // string name = 1;
      case 1: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) {
          DO_(::google::protobuf::internal::WireFormatLite::ReadString(
                input, this->mutable_name()));
          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
            this->name().data(), static_cast<int>(this->name().length()),
            ::google::protobuf::internal::WireFormatLite::PARSE,
            "firestore.client.UnknownDocument.name"));
        } else {
          goto handle_unusual;
        }
        break;
      }

      // .google.protobuf.Timestamp version = 2;
      case 2: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) {
          DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
               input, mutable_version()));
        } else {
          goto handle_unusual;
        }
        break;
      }

      default: {
      handle_unusual:
        if (tag == 0) {
          goto success;
        }
        DO_(::google::protobuf::internal::WireFormat::SkipField(
              input, tag, _internal_metadata_.mutable_unknown_fields()));
        break;
      }
    }
  }
success:
  // @@protoc_insertion_point(parse_success:firestore.client.UnknownDocument)
  return true;
failure:
  // @@protoc_insertion_point(parse_failure:firestore.client.UnknownDocument)
  return false;
#undef DO_
}

void UnknownDocument::SerializeWithCachedSizes(
    ::google::protobuf::io::CodedOutputStream* output) const {
  // @@protoc_insertion_point(serialize_start:firestore.client.UnknownDocument)
  ::google::protobuf::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // string name = 1;
  if (this->name().size() > 0) {
    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
      this->name().data(), static_cast<int>(this->name().length()),
      ::google::protobuf::internal::WireFormatLite::SERIALIZE,
      "firestore.client.UnknownDocument.name");
    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
      1, this->name(), output);
  }

  // .google.protobuf.Timestamp version = 2;
  if (this->has_version()) {
    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
      2, *this->version_, output);
  }

  if ((_internal_metadata_.have_unknown_fields() &&  ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
        (::google::protobuf::internal::GetProto3PreserveUnknownsDefault()   ? _internal_metadata_.unknown_fields()   : _internal_metadata_.default_instance()), output);
  }
  // @@protoc_insertion_point(serialize_end:firestore.client.UnknownDocument)
}

::google::protobuf::uint8* UnknownDocument::InternalSerializeWithCachedSizesToArray(
    bool deterministic, ::google::protobuf::uint8* target) const {
  (void)deterministic; // Unused
  // @@protoc_insertion_point(serialize_to_array_start:firestore.client.UnknownDocument)
  ::google::protobuf::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // string name = 1;
  if (this->name().size() > 0) {
    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
      this->name().data(), static_cast<int>(this->name().length()),
      ::google::protobuf::internal::WireFormatLite::SERIALIZE,
      "firestore.client.UnknownDocument.name");
    target =
      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
        1, this->name(), target);
  }

  // .google.protobuf.Timestamp version = 2;
  if (this->has_version()) {
    target = ::google::protobuf::internal::WireFormatLite::
      InternalWriteMessageToArray(
        2, *this->version_, deterministic, target);
  }

  if ((_internal_metadata_.have_unknown_fields() &&  ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
        (::google::protobuf::internal::GetProto3PreserveUnknownsDefault()   ? _internal_metadata_.unknown_fields()   : _internal_metadata_.default_instance()), target);
  }
  // @@protoc_insertion_point(serialize_to_array_end:firestore.client.UnknownDocument)
  return target;
}

size_t UnknownDocument::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:firestore.client.UnknownDocument)
  size_t total_size = 0;

  if ((_internal_metadata_.have_unknown_fields() &&  ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
    total_size +=
      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
        (::google::protobuf::internal::GetProto3PreserveUnknownsDefault()   ? _internal_metadata_.unknown_fields()   : _internal_metadata_.default_instance()));
  }
  // string name = 1;
  if (this->name().size() > 0) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::StringSize(
        this->name());
  }

  // .google.protobuf.Timestamp version = 2;
  if (this->has_version()) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::MessageSize(
        *this->version_);
  }

  int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = cached_size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
  return total_size;
}

void UnknownDocument::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:firestore.client.UnknownDocument)
  GOOGLE_DCHECK_NE(&from, this);
  const UnknownDocument* source =
      ::google::protobuf::internal::DynamicCastToGenerated<const UnknownDocument>(
          &from);
  if (source == NULL) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:firestore.client.UnknownDocument)
    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:firestore.client.UnknownDocument)
    MergeFrom(*source);
  }
}

void UnknownDocument::MergeFrom(const UnknownDocument& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:firestore.client.UnknownDocument)
  GOOGLE_DCHECK_NE(&from, this);
  _internal_metadata_.MergeFrom(from._internal_metadata_);
  ::google::protobuf::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  if (from.name().size() > 0) {

    name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
  }
  if (from.has_version()) {
    mutable_version()->::google::protobuf::Timestamp::MergeFrom(from.version());
  }
}

void UnknownDocument::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:firestore.client.UnknownDocument)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void UnknownDocument::CopyFrom(const UnknownDocument& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:firestore.client.UnknownDocument)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool UnknownDocument::IsInitialized() const {
  return true;
}

void UnknownDocument::Swap(UnknownDocument* other) {
  if (other == this) return;
  InternalSwap(other);
}
void UnknownDocument::InternalSwap(UnknownDocument* other) {
  using std::swap;
  name_.Swap(&other->name_);
  swap(version_, other->version_);
  _internal_metadata_.Swap(&other->_internal_metadata_);
  swap(_cached_size_, other->_cached_size_);
}

::google::protobuf::Metadata UnknownDocument::GetMetadata() const {
  protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto::protobuf_AssignDescriptorsOnce();
  return ::protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto::file_level_metadata[kIndexInFileMessages];
}


// ===================================================================

void MaybeDocument::InitAsDefaultInstance() {
  ::firestore::client::_MaybeDocument_default_instance_.no_document_ = const_cast< ::firestore::client::NoDocument*>(
      ::firestore::client::NoDocument::internal_default_instance());
  ::firestore::client::_MaybeDocument_default_instance_.document_ = const_cast< ::google::firestore::v1beta1::Document*>(
      ::google::firestore::v1beta1::Document::internal_default_instance());
  ::firestore::client::_MaybeDocument_default_instance_.unknown_document_ = const_cast< ::firestore::client::UnknownDocument*>(
      ::firestore::client::UnknownDocument::internal_default_instance());
}
void MaybeDocument::set_allocated_no_document(::firestore::client::NoDocument* no_document) {
  ::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
  clear_document_type();
  if (no_document) {
    ::google::protobuf::Arena* submessage_arena = NULL;
    if (message_arena != submessage_arena) {
      no_document = ::google::protobuf::internal::GetOwnedMessage(
          message_arena, no_document, submessage_arena);
    }
    set_has_no_document();
    document_type_.no_document_ = no_document;
  }
  // @@protoc_insertion_point(field_set_allocated:firestore.client.MaybeDocument.no_document)
}
void MaybeDocument::set_allocated_document(::google::firestore::v1beta1::Document* document) {
  ::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
  clear_document_type();
  if (document) {
    ::google::protobuf::Arena* submessage_arena = NULL;
    if (message_arena != submessage_arena) {
      document = ::google::protobuf::internal::GetOwnedMessage(
          message_arena, document, submessage_arena);
    }
    set_has_document();
    document_type_.document_ = document;
  }
  // @@protoc_insertion_point(field_set_allocated:firestore.client.MaybeDocument.document)
}
void MaybeDocument::clear_document() {
  if (has_document()) {
    delete document_type_.document_;
    clear_has_document_type();
  }
}
void MaybeDocument::set_allocated_unknown_document(::firestore::client::UnknownDocument* unknown_document) {
  ::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
  clear_document_type();
  if (unknown_document) {
    ::google::protobuf::Arena* submessage_arena = NULL;
    if (message_arena != submessage_arena) {
      unknown_document = ::google::protobuf::internal::GetOwnedMessage(
          message_arena, unknown_document, submessage_arena);
    }
    set_has_unknown_document();
    document_type_.unknown_document_ = unknown_document;
  }
  // @@protoc_insertion_point(field_set_allocated:firestore.client.MaybeDocument.unknown_document)
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int MaybeDocument::kNoDocumentFieldNumber;
const int MaybeDocument::kDocumentFieldNumber;
const int MaybeDocument::kUnknownDocumentFieldNumber;
const int MaybeDocument::kHasCommittedMutationsFieldNumber;
#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900

MaybeDocument::MaybeDocument()
  : ::google::protobuf::Message(), _internal_metadata_(NULL) {
  if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
    ::protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto::InitDefaultsMaybeDocument();
  }
  SharedCtor();
  // @@protoc_insertion_point(constructor:firestore.client.MaybeDocument)
}
MaybeDocument::MaybeDocument(const MaybeDocument& from)
  : ::google::protobuf::Message(),
      _internal_metadata_(NULL),
      _cached_size_(0) {
  _internal_metadata_.MergeFrom(from._internal_metadata_);
  has_committed_mutations_ = from.has_committed_mutations_;
  clear_has_document_type();
  switch (from.document_type_case()) {
    case kNoDocument: {
      mutable_no_document()->::firestore::client::NoDocument::MergeFrom(from.no_document());
      break;
    }
    case kDocument: {
      mutable_document()->::google::firestore::v1beta1::Document::MergeFrom(from.document());
      break;
    }
    case kUnknownDocument: {
      mutable_unknown_document()->::firestore::client::UnknownDocument::MergeFrom(from.unknown_document());
      break;
    }
    case DOCUMENT_TYPE_NOT_SET: {
      break;
    }
  }
  // @@protoc_insertion_point(copy_constructor:firestore.client.MaybeDocument)
}

void MaybeDocument::SharedCtor() {
  has_committed_mutations_ = false;
  clear_has_document_type();
  _cached_size_ = 0;
}

MaybeDocument::~MaybeDocument() {
  // @@protoc_insertion_point(destructor:firestore.client.MaybeDocument)
  SharedDtor();
}

void MaybeDocument::SharedDtor() {
  if (has_document_type()) {
    clear_document_type();
  }
}

void MaybeDocument::SetCachedSize(int size) const {
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* MaybeDocument::descriptor() {
  ::protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto::protobuf_AssignDescriptorsOnce();
  return ::protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}

const MaybeDocument& MaybeDocument::default_instance() {
  ::protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto::InitDefaultsMaybeDocument();
  return *internal_default_instance();
}

MaybeDocument* MaybeDocument::New(::google::protobuf::Arena* arena) const {
  MaybeDocument* n = new MaybeDocument;
  if (arena != NULL) {
    arena->Own(n);
  }
  return n;
}

void MaybeDocument::clear_document_type() {
// @@protoc_insertion_point(one_of_clear_start:firestore.client.MaybeDocument)
  switch (document_type_case()) {
    case kNoDocument: {
      delete document_type_.no_document_;
      break;
    }
    case kDocument: {
      delete document_type_.document_;
      break;
    }
    case kUnknownDocument: {
      delete document_type_.unknown_document_;
      break;
    }
    case DOCUMENT_TYPE_NOT_SET: {
      break;
    }
  }
  _oneof_case_[0] = DOCUMENT_TYPE_NOT_SET;
}


void MaybeDocument::Clear() {
// @@protoc_insertion_point(message_clear_start:firestore.client.MaybeDocument)
  ::google::protobuf::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  has_committed_mutations_ = false;
  clear_document_type();
  _internal_metadata_.Clear();
}

bool MaybeDocument::MergePartialFromCodedStream(
    ::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
  ::google::protobuf::uint32 tag;
  // @@protoc_insertion_point(parse_start:firestore.client.MaybeDocument)
  for (;;) {
    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
    tag = p.first;
    if (!p.second) goto handle_unusual;
    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
      // .firestore.client.NoDocument no_document = 1;
      case 1: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) {
          DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
               input, mutable_no_document()));
        } else {
          goto handle_unusual;
        }
        break;
      }

      // .google.firestore.v1beta1.Document document = 2;
      case 2: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) {
          DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
               input, mutable_document()));
        } else {
          goto handle_unusual;
        }
        break;
      }

      // .firestore.client.UnknownDocument unknown_document = 3;
      case 3: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) {
          DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
               input, mutable_unknown_document()));
        } else {
          goto handle_unusual;
        }
        break;
      }

      // bool has_committed_mutations = 4;
      case 4: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(32u /* 32 & 0xFF */)) {

          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
                 input, &has_committed_mutations_)));
        } else {
          goto handle_unusual;
        }
        break;
      }

      default: {
      handle_unusual:
        if (tag == 0) {
          goto success;
        }
        DO_(::google::protobuf::internal::WireFormat::SkipField(
              input, tag, _internal_metadata_.mutable_unknown_fields()));
        break;
      }
    }
  }
success:
  // @@protoc_insertion_point(parse_success:firestore.client.MaybeDocument)
  return true;
failure:
  // @@protoc_insertion_point(parse_failure:firestore.client.MaybeDocument)
  return false;
#undef DO_
}

void MaybeDocument::SerializeWithCachedSizes(
    ::google::protobuf::io::CodedOutputStream* output) const {
  // @@protoc_insertion_point(serialize_start:firestore.client.MaybeDocument)
  ::google::protobuf::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // .firestore.client.NoDocument no_document = 1;
  if (has_no_document()) {
    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
      1, *document_type_.no_document_, output);
  }

  // .google.firestore.v1beta1.Document document = 2;
  if (has_document()) {
    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
      2, *document_type_.document_, output);
  }

  // .firestore.client.UnknownDocument unknown_document = 3;
  if (has_unknown_document()) {
    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
      3, *document_type_.unknown_document_, output);
  }

  // bool has_committed_mutations = 4;
  if (this->has_committed_mutations() != 0) {
    ::google::protobuf::internal::WireFormatLite::WriteBool(4, this->has_committed_mutations(), output);
  }

  if ((_internal_metadata_.have_unknown_fields() &&  ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
        (::google::protobuf::internal::GetProto3PreserveUnknownsDefault()   ? _internal_metadata_.unknown_fields()   : _internal_metadata_.default_instance()), output);
  }
  // @@protoc_insertion_point(serialize_end:firestore.client.MaybeDocument)
}

::google::protobuf::uint8* MaybeDocument::InternalSerializeWithCachedSizesToArray(
    bool deterministic, ::google::protobuf::uint8* target) const {
  (void)deterministic; // Unused
  // @@protoc_insertion_point(serialize_to_array_start:firestore.client.MaybeDocument)
  ::google::protobuf::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // .firestore.client.NoDocument no_document = 1;
  if (has_no_document()) {
    target = ::google::protobuf::internal::WireFormatLite::
      InternalWriteMessageToArray(
        1, *document_type_.no_document_, deterministic, target);
  }

  // .google.firestore.v1beta1.Document document = 2;
  if (has_document()) {
    target = ::google::protobuf::internal::WireFormatLite::
      InternalWriteMessageToArray(
        2, *document_type_.document_, deterministic, target);
  }

  // .firestore.client.UnknownDocument unknown_document = 3;
  if (has_unknown_document()) {
    target = ::google::protobuf::internal::WireFormatLite::
      InternalWriteMessageToArray(
        3, *document_type_.unknown_document_, deterministic, target);
  }

  // bool has_committed_mutations = 4;
  if (this->has_committed_mutations() != 0) {
    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(4, this->has_committed_mutations(), target);
  }

  if ((_internal_metadata_.have_unknown_fields() &&  ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
        (::google::protobuf::internal::GetProto3PreserveUnknownsDefault()   ? _internal_metadata_.unknown_fields()   : _internal_metadata_.default_instance()), target);
  }
  // @@protoc_insertion_point(serialize_to_array_end:firestore.client.MaybeDocument)
  return target;
}

size_t MaybeDocument::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:firestore.client.MaybeDocument)
  size_t total_size = 0;

  if ((_internal_metadata_.have_unknown_fields() &&  ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
    total_size +=
      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
        (::google::protobuf::internal::GetProto3PreserveUnknownsDefault()   ? _internal_metadata_.unknown_fields()   : _internal_metadata_.default_instance()));
  }
  // bool has_committed_mutations = 4;
  if (this->has_committed_mutations() != 0) {
    total_size += 1 + 1;
  }

  switch (document_type_case()) {
    // .firestore.client.NoDocument no_document = 1;
    case kNoDocument: {
      total_size += 1 +
        ::google::protobuf::internal::WireFormatLite::MessageSize(
          *document_type_.no_document_);
      break;
    }
    // .google.firestore.v1beta1.Document document = 2;
    case kDocument: {
      total_size += 1 +
        ::google::protobuf::internal::WireFormatLite::MessageSize(
          *document_type_.document_);
      break;
    }
    // .firestore.client.UnknownDocument unknown_document = 3;
    case kUnknownDocument: {
      total_size += 1 +
        ::google::protobuf::internal::WireFormatLite::MessageSize(
          *document_type_.unknown_document_);
      break;
    }
    case DOCUMENT_TYPE_NOT_SET: {
      break;
    }
  }
  int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = cached_size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
  return total_size;
}

void MaybeDocument::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:firestore.client.MaybeDocument)
  GOOGLE_DCHECK_NE(&from, this);
  const MaybeDocument* source =
      ::google::protobuf::internal::DynamicCastToGenerated<const MaybeDocument>(
          &from);
  if (source == NULL) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:firestore.client.MaybeDocument)
    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:firestore.client.MaybeDocument)
    MergeFrom(*source);
  }
}

void MaybeDocument::MergeFrom(const MaybeDocument& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:firestore.client.MaybeDocument)
  GOOGLE_DCHECK_NE(&from, this);
  _internal_metadata_.MergeFrom(from._internal_metadata_);
  ::google::protobuf::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  if (from.has_committed_mutations() != 0) {
    set_has_committed_mutations(from.has_committed_mutations());
  }
  switch (from.document_type_case()) {
    case kNoDocument: {
      mutable_no_document()->::firestore::client::NoDocument::MergeFrom(from.no_document());
      break;
    }
    case kDocument: {
      mutable_document()->::google::firestore::v1beta1::Document::MergeFrom(from.document());
      break;
    }
    case kUnknownDocument: {
      mutable_unknown_document()->::firestore::client::UnknownDocument::MergeFrom(from.unknown_document());
      break;
    }
    case DOCUMENT_TYPE_NOT_SET: {
      break;
    }
  }
}

void MaybeDocument::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:firestore.client.MaybeDocument)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void MaybeDocument::CopyFrom(const MaybeDocument& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:firestore.client.MaybeDocument)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool MaybeDocument::IsInitialized() const {
  return true;
}

void MaybeDocument::Swap(MaybeDocument* other) {
  if (other == this) return;
  InternalSwap(other);
}
void MaybeDocument::InternalSwap(MaybeDocument* other) {
  using std::swap;
  swap(has_committed_mutations_, other->has_committed_mutations_);
  swap(document_type_, other->document_type_);
  swap(_oneof_case_[0], other->_oneof_case_[0]);
  _internal_metadata_.Swap(&other->_internal_metadata_);
  swap(_cached_size_, other->_cached_size_);
}

::google::protobuf::Metadata MaybeDocument::GetMetadata() const {
  protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto::protobuf_AssignDescriptorsOnce();
  return ::protobuf_firestore_2flocal_2fmaybe_5fdocument_2eproto::file_level_metadata[kIndexInFileMessages];
}


// @@protoc_insertion_point(namespace_scope)
}  // namespace client
}  // namespace firestore

// @@protoc_insertion_point(global_scope)
